home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / ggraph / symbols.c < prev    next >
C/C++ Source or Header  |  1989-07-12  |  10KB  |  294 lines

  1. #include <stdio.h>
  2. #include <errno.h>
  3. #include <strings.h>
  4. #include <math.h>
  5. #include "ggraph.h"
  6. #include "ggraphdefs.h"
  7.  
  8. /****************************************************************
  9.  *                                *
  10.  *    putcirclepoint - draw a circle around the point        *
  11.  *                x, y - point to use as center    *
  12.  *                                *
  13.  ****************************************************************/
  14. putcirclepoint (x, y)
  15. float   x,
  16.         y;
  17. {
  18.     if(version == SUN_GREMLIN)
  19.       fprintf (outfile, "ARC\n");
  20.     else
  21.       fprintf (outfile, "%d\n", CIRCLE);
  22.     fprintf(outfile, "%4.1f %4.1f\n", x, y);
  23.     fprintf(outfile, "%4.1f %4.1f\n", x + (SQRT2 * cg.symbolsz), 
  24.                  y + (SQRT2 * cg.symbolsz));
  25.     fprintf(outfile, "%4.1f %4.1f\n", x, y + cg.symbolsz);
  26.     fprintf(outfile, "%4.1f %4.1f\n", x, y - cg.symbolsz);
  27.     fprintf(outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y);
  28.     fprintf(outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y);
  29.  
  30.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  31.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  32. }
  33.  
  34. /****************************************************************
  35.  *                                *
  36.  *    putboxpoint - draw a box around the point        *
  37.  *                x, y - point to use as center    *
  38.  *                                *
  39.  ****************************************************************/
  40. putboxpoint (x, y)
  41. float   x,
  42.         y;
  43. {
  44.     if(version == SUN_GREMLIN)
  45.       fprintf (outfile, "VECTOR\n");
  46.     else
  47.       fprintf (outfile, "%d\n", LINE);
  48.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  49.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y + cg.symbolsz);
  50.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y + cg.symbolsz);
  51.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y - cg.symbolsz);
  52.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  53.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  54.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  55. }
  56.  
  57. /****************************************************************
  58.  *                                *
  59.  *    putcrosspoint - draw a cross on the point        *
  60.  *                x, y - point to use as center    *
  61.  *                                *
  62.  ****************************************************************/
  63. putcrosspoint (x, y)
  64. float   x,
  65.         y;
  66. {
  67.     if(version == SUN_GREMLIN)
  68.       fprintf (outfile, "VECTOR\n");
  69.     else
  70.       fprintf (outfile, "%d\n", LINE);
  71.     fprintf (outfile, "%4.1f %4.1f\n", x, y + cg.symbolsz);
  72.     fprintf (outfile, "%4.1f %4.1f\n", x, y - cg.symbolsz);
  73.     fprintf (outfile, "%4.1f %4.1f\n", x, y);
  74.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y);
  75.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y);
  76.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  77.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  78. }
  79.  
  80. /****************************************************************
  81.  *                                *
  82.  *    putxpoint - draw a star on the point            *
  83.  *                x, y - point to use as center    *
  84.  *                                *
  85.  ****************************************************************/
  86. putxpoint (x, y)
  87. float   x,
  88.         y;
  89. {
  90.     if(version == SUN_GREMLIN)
  91.       fprintf (outfile, "VECTOR\n");
  92.     else
  93.       fprintf (outfile, "%d\n", LINE);
  94.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y + cg.symbolsz);
  95.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  96.     fprintf (outfile, "%4.1f %4.1f\n", x, y);
  97.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y + cg.symbolsz);
  98.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y - cg.symbolsz);
  99.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  100.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  101. }
  102.  
  103. /****************************************************************
  104.  *                                *
  105.  *    puttripoint - draw a triangle on the point        *
  106.  *                x, y - point to use as center    *
  107.  *                                *
  108.  ****************************************************************/
  109. puttripoint (x, y)
  110. float   x,
  111.         y;
  112. {
  113.     if(version == SUN_GREMLIN)
  114.       fprintf (outfile, "VECTOR\n");
  115.     else
  116.       fprintf (outfile, "%d\n", LINE);
  117.     fprintf (outfile, "%4.1f %4.1f\n", x, y + cg.symbolsz);
  118.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  119.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y - cg.symbolsz);
  120.     fprintf (outfile, "%4.1f %4.1f\n", x, y + cg.symbolsz);
  121.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  122.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  123. }
  124.  
  125. /****************************************************************
  126.  *                                *
  127.  *    pututripoint - draw an upside down triangle        *
  128.  *                x, y - point to use as center    *
  129.  *                                *
  130.  ****************************************************************/
  131. pututripoint (x, y)
  132. float   x,
  133.         y;
  134. {
  135.     if(version == SUN_GREMLIN)
  136.       fprintf (outfile, "VECTOR\n");
  137.     else
  138.       fprintf (outfile, "%d\n", LINE);
  139.     fprintf (outfile, "%4.1f %4.1f\n", x, y - cg.symbolsz);
  140.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y + cg.symbolsz);
  141.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y + cg.symbolsz);
  142.     fprintf (outfile, "%4.1f %4.1f\n", x, y - cg.symbolsz);
  143.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  144.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  145. }
  146.  
  147. /****************************************************************
  148.  *                                *
  149.  *    putxboxpoint - draw a crossed box on the point        *
  150.  *                x, y - point to use as center    *
  151.  *                                *
  152.  ****************************************************************/
  153. putxboxpoint (x, y)
  154. float   x,
  155.         y;
  156. {
  157.     if(version == SUN_GREMLIN)
  158.       fprintf (outfile, "VECTOR\n");
  159.     else
  160.       fprintf (outfile, "%d\n", LINE);
  161.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  162.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y + cg.symbolsz);
  163.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y + cg.symbolsz);
  164.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y - cg.symbolsz);
  165.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  166.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y + cg.symbolsz);
  167.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  168.     fprintf (outfile, "%4.1f %4.1f\n", x, y);
  169.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y + cg.symbolsz);
  170.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y - cg.symbolsz);
  171.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  172.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  173. }
  174.  
  175. /****************************************************************
  176.  *                                *
  177.  *    putcboxpoint - draw a starred box on the point        *
  178.  *                x, y - point to use as center    *
  179.  *                                *
  180.  ****************************************************************/
  181. putcboxpoint (x, y)
  182. float   x,
  183.         y;
  184. {
  185.     if(version == SUN_GREMLIN)
  186.       fprintf (outfile, "VECTOR\n");
  187.     else
  188.       fprintf (outfile, "%d\n", LINE);
  189.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  190.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y + cg.symbolsz);
  191.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y + cg.symbolsz);
  192.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y - cg.symbolsz);
  193.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  194.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y);
  195.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y);
  196.     fprintf (outfile, "%4.1f %4.1f\n", x, y);
  197.     fprintf (outfile, "%4.1f %4.1f\n", x, y + cg.symbolsz);
  198.     fprintf (outfile, "%4.1f %4.1f\n", x, y - cg.symbolsz);
  199.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  200.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  201. }
  202.  
  203. /****************************************************************
  204.  *                                *
  205.  *    putdiapoint - draw a diamond on the point        *
  206.  *                x, y - point to use as center    *
  207.  *                                *
  208.  ****************************************************************/
  209. putdiapoint (x, y)
  210. float   x,
  211.         y;
  212. {
  213.     if(version == SUN_GREMLIN)
  214.       fprintf (outfile, "VECTOR\n");
  215.     else
  216.       fprintf (outfile, "%d\n", LINE);
  217.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y);
  218.     fprintf (outfile, "%4.1f %4.1f\n", x , y - cg.symbolsz);
  219.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y);
  220.     fprintf (outfile, "%4.1f %4.1f\n", x, y + cg.symbolsz);
  221.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y);
  222.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  223.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  224. }
  225.  
  226. /****************************************************************
  227.  *                                *
  228.  *    putcdiapoint - draw a crossed diamond on the point    *
  229.  *                x, y - point to use as center    *
  230.  *                                *
  231.  ****************************************************************/
  232. putcdiapoint (x, y)
  233. float   x,
  234.         y;
  235. {
  236.     if(version == SUN_GREMLIN)
  237.       fprintf (outfile, "VECTOR\n");
  238.     else
  239.       fprintf (outfile, "%d\n", LINE);
  240.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y);
  241.     fprintf (outfile, "%4.1f %4.1f\n", x , y - cg.symbolsz);
  242.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y);
  243.     fprintf (outfile, "%4.1f %4.1f\n", x, y + cg.symbolsz);
  244.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y);
  245.     fprintf (outfile, "%4.1f %4.1f\n", x, y + cg.symbolsz);
  246.     fprintf (outfile, "%4.1f %4.1f\n", x, y - cg.symbolsz);
  247.     fprintf (outfile, "%4.1f %4.1f\n", x, y);
  248.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y);
  249.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y);
  250.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  251.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  252. }
  253.  
  254. draw_symbol(symtype, symx, symy)
  255. int symtype;
  256. float symx, symy;
  257. {
  258.     switch (symtype) {
  259.     case BOX: 
  260.         putboxpoint (symx, symy);
  261.         break;
  262.     case RING: 
  263.         putcirclepoint (symx, symy);
  264.         break;
  265.     case CROSS: 
  266.         putcrosspoint (symx, symy);
  267.         break;
  268.     case STAR: 
  269.         putxpoint (symx, symy);
  270.         break;
  271.     case TRIANGLE: 
  272.         puttripoint (symx, symy);
  273.         break;
  274.     case UTRIANGLE: 
  275.         pututripoint (symx, symy);
  276.         break;
  277.     case CROSSBOX: 
  278.         putcboxpoint (symx, symy);
  279.         break;
  280.     case STARBOX: 
  281.         putxboxpoint (symx, symy);
  282.         break;
  283.     case DIAMOND: 
  284.         putdiapoint (symx, symy);
  285.         break;
  286.     case CROSSDIAMOND: 
  287.         putcdiapoint (symx, symy);
  288.         break;
  289.     case NOSYMBOL: 
  290.     default: 
  291.         break;
  292.     }
  293. }
  294.